import {log} from "./log";

interface FormatSeconds {
  hours: string;
  minutes: string;
  seconds: string;
}

export function convertSeconds(seconds: number): FormatSeconds {
  const results = { hours: '00', minutes: '00', seconds: '00' };
  if (isNaN(+seconds)) {
    log('Invalid value sent to convert-seconds', 'error');
  } else {
    results.hours = Math.floor(seconds / 60 / 60).toString().padStart(2, '0');
    results.minutes = Math.floor((seconds / 60) % 60).toString().padStart(2, '0');
    results.seconds = Math.floor(seconds % 60).toString().padStart(2, '0');
  }
  return results;
}
